package cn.edu.hqu.cst.crj.sharedperences;

import android.content.Context;
import android.content.SharedPreferences;



public class SPHelper {
    private static final String fileName="mydata";
    //保存数据
    public static boolean saveUserInfo(Context context,String username,String password){
        boolean flag=false;
        SharedPreferences sp = context.getSharedPreferences(fileName,Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=sp.edit();
        editor.putString("username",username);
        editor.putString("password",password);
        editor.commit();
        flag=true;
        return  flag;
    }

    public static UserInfo getUserInfo(Context context){
        UserInfo user = null;
        SharedPreferences sp=context.getSharedPreferences(fileName,Context.MODE_PRIVATE);
        String username=sp.getString("username",null);
        String password=sp.getString("password",null);
        user=new UserInfo(username,password);
        return user;
    }





}